package com.zhentao;

import com.zhentao.file.service.FileStorageService;
import io.minio.MinioClient;
import io.minio.ObjectWriteResponse;
import io.minio.PutObjectArgs;
import io.minio.errors.*;
import org.springframework.beans.factory.annotation.Autowired;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;

public class TestUpload {


    public static void main(String[] args) throws IOException, ServerException, InvalidBucketNameException, InsufficientDataException, ErrorResponseException, NoSuchAlgorithmException, InvalidKeyException, InvalidResponseException, XmlParserException, InternalException {
        System.err.println(1231312);
//        //创建minio客户端
//        MinioClient minioClient = MinioClient.builder().credentials("minioadmin", "minioadmin")
//                .endpoint("http://192.168.6.150:19000").build();
//        FileInputStream inputStream = new FileInputStream("C://Users//86132//Desktop//03.html");
//        PutObjectArgs test02 = PutObjectArgs.builder().bucket("test02")
//                .object("03.html")
//                .contentType("text/html")
//                .stream(inputStream, inputStream.available(), -1)
//                .build();
//
//        ObjectWriteResponse object = minioClient.putObject(test02);
//        System.out.println(object);
//
//        String url = minioClient.getObjectUrl(test02.bucket(), test02.object());
//        System.err.println(url);


        //        //创建minio客户端
//        MinioClient minioClient = MinioClient.builder().credentials("minioadmin", "minioadmin")
//                .endpoint("http://192.168.6.150:9090/").build();
//        //
//        FileInputStream fileInputStream = new FileInputStream("C://Users//86132//Desktop//03.html");
//        PutObjectArgs test = PutObjectArgs.builder().bucket("test02")
//                .object("03.html")
//                .contentType("text/html")//文件类型
//                .stream(fileInputStream, fileInputStream.available(), -1)
//                .build();
//        ObjectWriteResponse objectWriteResponse = minioClient.putObject(test);;
//        System.err.println(objectWriteResponse);

    }
}
